<?php
/**
 * Created by PhpStorm.
 * User: User
 * Date: 2017/10/9
 * Time: 18:30
 */

class Circle
{

 private $r;
 private $d='abc';
 public function  __construct($r)
 {
     $this->r=$r;
 }

    public  function  __clone(){
     $this->r=0;
 }
    public function  __toString()
    {
        return 'circle.r'.$this->r;
    }
    public function __call($name, $arguments)
    {
        die("你调用的方法".$name."不存在!");
    }

    public  function getArea(){
     return 3.14*$this->r*$this->r;
 }

 public function __set($name,$value){
     if($name=='r' &&$value<0){
         $this->r=0;
     }else{
         $this->$name=$value;
     }
 }
}
public function __sleep(){
    return array("r");
}
$c=new Circle(3);
$str=serialize($c);
echo  $str;

$d=unserialize($str);
echo"<br/>";
var_dump($d);
